package printer.impl;

import java.util.Set;

import pojo.Customer;
import printer.DataPrinter;

public class DataPrinterImpl implements DataPrinter {

	public StringBuilder print(Set<Customer> customers, String format) {
		String str="";
		if("xml".equals(format))
		{
			str+=("<customer>\r\n");
			for(Customer c : customers)
			{
				str+=("	<customer id="+c.getId()+">\r\n");
				str+=("		<name>"+c.getName()+"</name>\r\n");
				str+=("		<date>"+c.getDate()+"</date>\r\n");
				str+=("		<email>"+c.getEmail()+"</email>\r\n");
				str+=("	</customer>\r\n");
			}
			str+=("</customer>\r\n");
			return new StringBuilder(str);
		}
		else if("line".equals(format))
		{
			for(Customer c : customers)
			{
				str+=(c.getId()+" "+c.getName()+" "+c.getEmail()+" "+c.getSex()+" "+c.getDate()+"\r\n");
			}
			return new StringBuilder(str);
		}
		return null;
	}
	
}
